package com.qing.springcloud.controller;

import com.qing.springcloud.annotation.RequireLogin;
import com.qing.springcloud.dto.user.UserLoginDTO;
import com.qing.springcloud.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author caozhipeng
 * @date 2025/7/16
 *
 */
@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    public String login(@RequestBody UserLoginDTO userLoginDTO) {
        return loginService.login(userLoginDTO);
    }

    @PostMapping("/logout")
    @RequireLogin
    public void logout() {
        loginService.logout();
    }
}
